﻿namespace Net.AOI
{
    /// <summary>
    /// 九宫格格子物体接口
    /// </summary>
    public interface IGridObject
    {
        /// <summary>
        /// 唯一标识
        /// </summary>
        long Identity { get; set; }
        /// <summary>
        /// 格子的位置 { get => transform.Position; set => transform.Position = value; }
        /// </summary>
        Vector3 Position { get; set; }
        /// <summary>
        /// 当前所在的格子
        /// </summary>
        Grid Grid { get; set; }
        /// <summary>
        /// 主角? true:其他演员进入或退出都会通知自己 false:当自己进入新的格子时, 别人会通知你进来了, 当你退出旧的格子时, 别人也会通知你退出了旧的格子, 而你是无感知的
        /// </summary>
        bool MainRole { get; set; }
        /// <summary>
        /// 当初始化完成后调用
        /// </summary>
        void OnInit();
        /// <summary>
        /// 当格子物体进入感兴趣区域
        /// </summary>
        /// <param name="gridObject">进入格子的物体</param>
        void OnEnter(IGridObject gridObject);
        /// <summary>
        /// 当格子物体退出感兴趣区域
        /// </summary>
        /// <param name="gridObject">离开格子的物体</param>
        void OnExit(IGridObject gridObject);
        /// <summary>
        /// 当物体进入格子
        /// </summary>
        /// <param name="enterGrid">进入的格子</param>
        void OnEnterGrid(Grid enterGrid);
        /// <summary>
        /// 当物体离开格子
        /// </summary>
        /// <param name="leaveGrid">离开的格子</param>
        void OnLeaveGrid(Grid leaveGrid);
    }

    /// <summary>
    /// 提供格子更新接口
    /// </summary>
    public interface IGridUpdate
    {
        /// <summary>
        /// 当格子物体更新
        /// </summary>
        void OnUpdate();
    }
}
